<?php
/**注意此文档为UTF-8的编码.
 * Created on 2010-10-2
 *
 * @author EXT <isrn@qq.com>
 *
 */
include ('../../includes/global.php');
include ('../global.php');
include ("../power.php");
include ("../clas/ext.php");
$plugurl=array();$plugjs=array();$fckplugin='';
function grv($type,$blm,$dvalue=false){
	//print_r($type);
	if($dvalue){
		return $dvalue;
		}else{
		switch($type){
				case 'function':{
					$a=explode('#',$blm);
					return $a[0]($a[1]);
					break;
					}
				case '$_GET':{
					return	$_GET[$blm];
					break;
					}
				case '$_SESSION':{
					return	$_SESSION[$blm];
					break;
					}
				case '$_POST':{
					return	$_POST[$blm];
					break;
					}
				case '$_COOKIE':{
					return	$_COOKIE[$blm];
					break;
					}
				case '$_SERVER':{
					return	$_SERVER[$blm];
					break;
					}
				case '$_ENV':{
					return	$_ENV[$blm];
					break;
					}
				case '$_FILES':{
					return	$_FILES[$blm];
					break;
					}
				case '0':{
					return $blm;
					break;
					}
				case '1':{
					break;
					}
				default:{
					return $blm;
					break;
					}
			
				}
			}
	}
Tr('index.php','thisurl');Tr('信息','thistitle');$tmpml='program/';Tr($_GET['tid'],'tid');
Tr('5','pagenum');$paixu=array('zd'=>'id','order'=>'DESC');Tr($paixu,'paixu');Tr($_GET['tid'],'rightid');
Tr($_REQUEST['lg'],'lg');Tr($_REQUEST['bdid'],'bdid');Tr($_REQUEST['bdtid'],'bdtid');


//$_SESSION['rcg']!='A'&&$_SESSION['rcg']['zdgxkey'][$_GET['tid']]=1;$_GET['tid']='105';$_POST['tid']='105';
/*$showcf=array(
			  0=>array('title'=>'信息浏览','zd'=>array('tt','ct','pic1','input1','input2','ubb1'))Tr('106','rightid');
			  );

$listcf=array('show'=>array('tt','ct','pic1','input1','input2'),
			'xnlist'=>array(
							array('id'=>451,'fname'=>'num','type'=>'input','name'=>'数量','wd'=>100,'url'=>""),
							array('id'=>450,'fname'=>'yuding','type'=>'button','name'=>'预订','wd'=>100,'url'=>"")
							),
			'gj'=>array('user','ct','usertype'),
			//'ss'=>'ct',//olny one
			//'pt'=>" and user like '".$_SESSION['userinfo']['user']."' ",//sql
			'editdisble'=>array('tt','ct','pic1','input1','input2','ubb1'),
			//'zdgx'=>array('ct'),
			//'zdgxkey'=>array('ct'),
			'save'=>array('user','ct'),
			'zd'=>array('user','ct')
						  );
*/
switch($_REQUEST['op']){
	case 'list':{
		$_REQUEST['lg']!=''&&$condition=" and lg like '".$_REQUEST['lg']."' ";
			$fldata=Dgd(array(
			  'db'=>'d_sevenel',
			  'cd'=>"tid = '".$_GET['tid']."' ".$condition." order by px asc ",
			  'tn'=>"fld"
			));
		Tr($_GET['bdtid'],'bdtid');
		Tr($_GET['bdid'],'bdid');
		if(count($listcf['show'])>0){
				foreach($fldata as $key =>$v){
						if(in_array($v['fname'],$listcf['show'])){
							$xr[]=$v;
							}
					}
					   }else{
				foreach($fldata as $key =>$v){
						if($v['xr']==0){
							$xr[]=$v;
							}
					}
						   }
		if(count($listcf['xnlist'])>0){
				foreach($listcf['xnlist'] as $v){
							$xr[]=$v;
							}
			}
		Tr($xr,'xr');
		if(count($listcf['gj'])>0){
				foreach($fldata as $key =>$v){
						if(in_array($v['fname'],$listcf['gj'])){
							$gj[]=$v;
							}
					}
					   }else{
				foreach($fldata as $key =>$v){
						if($v['gj']==1){
							$gj[]=$v;
							}
					}
						   }
		if($gj!=''){
		foreach($gj as $key =>$value){$js[]=EXT::GG($value['id']);}
		}
		Tr($ckbox,'ckbox');
		Tr($js,'js');$gj&&Tr('1','gjright');
		if($listcf['ss']){Tr($listcf['ss'],'titlesearch');}else{Tr('tt','titlesearch');}
		$tree=Dgd(array(
			  'db'=>'d_sevenel',
			  'cd'=>"id = '".$_GET['tid']."' ",
			  'tn'=>"tree",
			  'limit'=>1
			));
		Tr($tree,'tree');
		if($tree['expand']){
		$fstree=Dgd(array(
			  'db'=>'d_sevenel',
			  'cd'=>"id in (0,".$tree['expand'].") ",
			  'tn'=>"tree"
			));}
		$fsstr='';
		if($fstree){
		foreach($fstree as $fsvalue){
			$ttree=Dgd(array(
		  'db'=>'d_sevenel',
		  'cd'=>"id = ".$fsvalue['id']."",
		  'tn'=>"tree",
		  'limit'=>'1'
		  ));
		if($ttree['config']!=''&&$ttree['config']!='{"lg":""}'){$fsstr.=",{xtype:\"button\",text:\"添加".$fsvalue['title']."\",iconCls:\"fsadd\",pressed:true,handler:function(){
				var record = grid.getStore().getAt(rowIndex); 
				fsadd('".$fsvalue['id']."','".$fsvalue['title']."',\"./dy/index.php?op=loaddata&tid=".$fsvalue['id']."&bdtid=".$_GET['tid']."&bdid=\",record.data.id);		}}
				,{xtype:\"button\",text:\"浏览".$fsvalue['title']."\",iconCls:\"fslist\",pressed:true,handler:function(){
				var record = grid.getStore().getAt(rowIndex); 
				fslist('".$fsvalue['id']."','".$fsvalue['title']."',\"./dy/index.php?tid=".$fsvalue['id']."&bdtid=".$_GET['tid']."&bdid=\",record.data.id);
					}}";				
}else{		$fsstr.=",{xtype:\"button\",text:\"添加".$fsvalue['title']."\",iconCls:\"fsadd\",pressed:true,handler:function(){
				var record = grid.getStore().getAt(rowIndex); 
				fsadd('".$fsvalue['id']."','".$fsvalue['title']."',\"./show1/i.php?op=add&tid=".$fsvalue['id']."&bdtid=".$_GET['tid']."&bdid=\",record.data.id);		}}
				,{xtype:\"button\",text:\"浏览".$fsvalue['title']."\",iconCls:\"fslist\",pressed:true,handler:function(){
				var record = grid.getStore().getAt(rowIndex); 
				fslist('".$fsvalue['id']."','".$fsvalue['title']."',\"./show1/l.php?op=list&tid=".$fsvalue['id']."&bdtid=".$_GET['tid']."&bdid=\",record.data.id);
					}}";				
}
			}}
		Tr($fsstr,'fstree');
		
		$table=Dgd(array(
			  'db'=>'d_sevenel',
			  'cd'=>"id = '".$tree['table']."' ",
			  'tn'=>"datamod",
			  'limit'=>1
			));
		Tr($table,'table');
		
		Ts('dy/list.html');
		break;
		}
	case 'fy':{
			if($_SESSION['rcg']!='A'&&!$_SESSION['rcg']['c'][$_POST['tid']]){
				$pt=$listcf['pt'];
				}
			$_REQUEST['lg']!=''&&$lgcondition=" and lg like '".$_REQUEST['lg']."' ";
			$fldata=Dgd(array(
			  'db'=>'d_sevenel',
			  'cd'=>"tid = '".$_POST['tid']."' ".$lgcondition." order by px asc ",
			  'tn'=>"fld"
			));
			$zhuanyi=array();
			$btsc=array();
			$gjsc=array();
			foreach($fldata as $key=>$value){
					if($value['zy']==1){
						$zhuanyi[]=$value;
						}
					if($value['bt']==1){
						$btsc[$value['fname']]=$value['type'];
						}
				}
			$condition='';
			//$_POST['user']&&$condition.="and user like '%".$_POST['user']."%' ";
			$_POST['bdtid']&&$condition.="and bdtid = '".$_POST['bdtid']."' ";
			$_POST['bdid']&&$condition.="and bdid = '".$_POST['bdid']."' ";
			if(count($listcf['gj'])>0){
					foreach($fldata as $key =>$v){
							if(in_array($v['fname'],$listcf['gj'])){
								$gj[]=$v;
								}
						}
						   }else{
					foreach($fldata as $key =>$v){
							if($v['gj']==1){
								$gj[]=$v;
								}
						}
							   }
			 if($gj!=''){
				 $xzt=array('combo','recommend','radiogroup','combo1');
				foreach($gj as $value){
					if(in_array($value['type'],$xzt)){
					$_POST[$value['fname']]!=''&&$condition.="and ".$value['fname']." = '".$_POST[$value['fname']]."' ";
						}else{
							if($value['type']=='checkboxgroup'){
								if($_POST[$value['fname']]){
								 foreach($_POST[$value['fname']] as $cv){
					$cv!=''&&$condition.="and ".$value['fname']." like '%".$cv."%' ";
									 }
									}
								}else{
					$_POST[$value['fname']]!=''&&$condition.="and ".$value['fname']." like '%".$_POST[$value['fname']]."%' ";
									}
							}
					} 
				 }
			$dbinfo=Dgd(array(
					  'db'=>'d_sevenel',
					  'tn'=>$_POST['dbname'],
					  'start'=>$_POST['start'],
					  'limit'=>$_POST['limit'],
					  'total'=>true,
					 // 'ce'=>1,
					  'cd'=>" 1 and tid = '".$_POST['tid']."' ".$condition."  and del != '1' ".$pt." ".$lgcondition." order by ".$paixu['zd']."  ".$paixu['order']."  "
					  ));
			//统计
			
			
			//转换
		$tempb=0;	
		foreach($dbinfo['data'] as $key =>$value){
//							$tempb+=$value['ct'];	

						foreach($zhuanyi as $zyv){
								switch($zyv['type']){
									case 'fileup':{
										//echo $dbinfo['data'][$key][$zyv['fname']];
										$config=json_decode($zyv['cfg'],true);
										$dvalue=array( 0=>array('rar','zip','tar','.tz'),
													   1=>array('jpg','gif','png','bmp'),
													   2=>array('mp3','mp4','avi','wmv','mid','.rm','mvb','mov','wma','wav'),
													   3=>array('doc','xls','txt','ocx','lsx','ppt','pdf','chm'),
													   4=>array('doc','xls','txt','ocx','lsx','ppt','pdf','chm','mp3','mp4','avi','wmv','mid','.rm','mvb','mov','wma','wav','jpg','gif','png','bmp','rar','zip','tar','.tz')		   
															   );
										$otype=substr(strtolower($dbinfo['data'][$key][$zyv['fname']]),-3);
												if(in_array($otype,$dvalue[0])){
												$dbinfo['data'][$key][$zyv['fname']]="<a href=\"/uplods/pic/".$dbinfo['data'][$key][$zyv['fname']]."\" target='_blank'><img src=\"../img/archive.png\">下载[Download]</a>";
													}
												if(in_array($otype,$dvalue[1])){
													if($config['sl1']==1){
													$dbinfo['data'][$key][$zyv['fname']]="<img src=\"/uplods/thumb1/".$dbinfo['data'][$key][$zyv['fname']]."\" >";	
														}elseif($config['sl2']==1){
													$dbinfo['data'][$key][$zyv['fname']]="<img src=\"/uplods/thumb2/".$dbinfo['data'][$key][$zyv['fname']]."\" >";	
															}elseif($config['sypic']==1||$config['sytxt']==1){
													$dbinfo['data'][$key][$zyv['fname']]="<img src=\"/uplods/sytp/".$dbinfo['data'][$key][$zyv['fname']]."\"  width=\"100px\">";	
															}else{
													$dbinfo['data'][$key][$zyv['fname']]="<img src=\"/uplods/pic/".$dbinfo['data'][$key][$zyv['fname']]."\"  width=\"100px\">";	
																}
													}
												if(in_array($otype,$dvalue[2])){
												$dbinfo['data'][$key][$zyv['fname']]="<a href=\"/uplods/pic/".$dbinfo['data'][$key][$zyv['fname']]."\" target='_blank'><img src=\"../img/film_link.png\">下载[Download]</a>";
													}
												if(in_array($otype,$dvalue[3])){
												$dbinfo['data'][$key][$zyv['fname']]="<a href=\"/uplods/pic/".$dbinfo['data'][$key][$zyv['fname']]."\" target='_blank'><img src=\"../img/report_word.png\">下载[Download]</a>";
													}
										break;	
										}
									case 'radiogroup':{	
									$tempxx = json_decode($zyv['zyz'],true);
									foreach($tempxx as $value){
											if($value['yv']==$dbinfo['data'][$key][$zyv['fname']]){
											$dbinfo['data'][$key][$zyv['fname']]=$value['xv'];
												}
										}
										break;
										}
									case 'checkboxgroup':{	
									$tempxx = json_decode($zyv['zyz'],true);
									$nowv=explode('#_#',$dbinfo['data'][$key][$zyv['fname']]);
									$dbinfo['data'][$key][$zyv['fname']]='';
									foreach($tempxx as $value){
											if(in_array($value['yv'],$nowv)){
											$dbinfo['data'][$key][$zyv['fname']].=$value['xv']."<BR>";
												}
										}
										break;
										}
									case 'combo':{	
									$tempxx = json_decode($zyv['zyz'],true);
									foreach($tempxx as $value){
											if($value['yv']==$dbinfo['data'][$key][$zyv['fname']]){
											$dbinfo['data'][$key][$zyv['fname']]=$value['xv'];
												}
										}
										break;
										}
									case 'combo1':{
										$config =json_decode($zyv['cfg'],true);
										$tq=Dgd(array(
										  'db'=>'d_sevenel',
										  'tn'=>$config['table'],
										  'cd'=> " ".$config['y']." = '".$dbinfo['data'][$key][$zyv['fname']]."' and  ".$config['conditon'],
										  'limit'=>1

										  ));
									$dbinfo['data'][$key][$zyv['fname']]=$tq[$config['x']];
										break;
								}
									case 'recommend':{	
										$config=json_decode($zyv['cfg'],true);
										if($dbinfo['data'][$key][$zyv['fname']]!=0){
											$dbinfo['data'][$key][$zyv['fname']]="<a href=\"#\" onclick='gxzd(\"".$dbinfo['data'][$key]['id']."\",\"".$zyv['fname']."\",\"0\")' title=\"推荐中！单击取消推荐\"  >  <img src=\"../img/".$config['paixu']."\"></a> ".(($config['px'])?("<a href=\"#\"  title=\"排序[order]\"  onclick='tjpx(\"".$_POST['tid']."@".$_POST['dbname']."\",\"".$zyv['fname']."\")' >   <img src=\"../img/sucaiwcom8170000bzc.gif\" ait=\"排序[order]\"></a>"):(""))." ";
												}else{
											$dbinfo['data'][$key][$zyv['fname']]="<a href=\"#\" onclick='gxzd(\"".$dbinfo['data'][$key]['id']."\",\"".$zyv['fname']."\",\"1\")'  title=\"未推荐！单击推荐\"  ><img src=\"../img/flag.png\"></a>  ".(($config['px'])?("<a href=\"#\"  title=\"排序[order]\"  onclick='tjpx(\"".$_POST['tid']."@".$_POST['dbname']."\",\"".$zyv['fname']."\")' >   <img src=\"../img/sucaiwcom8170000bzc.gif\" ait=\"排序[order]\"></a>"):(""))."";
													}
										break;
										}
									}
							
							}
/*						$dbinfo['data'][$key]['yuding']="<input type='button' value='下订单' onclick='yuding(".$dbinfo['data'][$key]['id'].")'/>";
						$dbinfo['data'][$key]['num']="<input type='text' value='1' name='num".$dbinfo['data'][$key]['id']."' id='num".$dbinfo['data'][$key]['id']."' />";
*/				}
/*		
			$tempz=$d_sevenel->Dqsql("select sum(ct) as total from  `se_user` where tid = '".$_POST['tid']."'  and del != '1' ");
    		$dbinfo['dq']=$tempb;
    		$dbinfo['zong']=$tempz[0]['total'];
*/			echo json_encode($dbinfo);
			break;
		}
	case 'width_change':{
	$id=$_POST['id'];
	Du('sevenel','fld',array('wd'=>$_POST['width']),'id',$id,1);
	echo 'ok';
	break;
	}
	case 'del':{
	$_POST['del']=1;
	$_POST['ids']=json_decode(stripslashes($_POST['ids']));
	if(is_array($_POST['ids'])){
		foreach($_POST['ids'] as $id){
			Du('sevenel',$_POST['dbname'],$_POST,'id',$id,0);
			}				   
		}else{
			Du('sevenel',$_POST['dbname'],$_POST,'id',$id,0);
			}
	 echo '{success:true,msg:\'ok\'}';
	break;
	}
	case 'add':{
		$tree_id = $_GET['tid'];
		Tr($_GET['tid'],'tid');
		Tr($_GET['bdtid'],'bdtid');
		Tr($_GET['bdid'],'bdid');
		Tr($_GET['gid'],'gid');

		$tree=Dgd(array(
			  'db'=>'d_sevenel',
			  'cd'=>"id = $tree_id",
			  'tn'=>"tree",
			  'limit'=>1
			));
			$tname=gettabname($tree['table'],$dbcfg['prefix'],true);
			Tr($tname,'tname');
		if($_GET['id']){
			Tr($_GET['id'],'id');
				$fdada=Dgd(array(
					  'db'=>'d_sevenel',
					  'cd'=>" id = '".$_GET['id']."' and del != '1' ",
					  'tn'=>"$tname",
					  'limit'=>1
					));
				Tr(preg_replace("/[\s]{2,}/","",$fdada['lg']),'lg');
				}
		if($_GET['id']==0){
			Tr('添加','action');
		}else{
			Tr('编辑','action');
		}
			$_REQUEST['lg']!=''&&$condition=" and lg like '".$_REQUEST['lg']."' ";
			$fldata=Dgd(array(
			  'db'=>'d_sevenel',
			  'cd'=>"tid = '".$_GET['tid']."' ".$condition." order by px asc ",
			  'tn'=>"fld"
			));

		
		$fcf='';
							$fcf.="{
								xtype:'fieldset',
								title: '信息浏览',
								autoHeight: true,
								items: [";	
									foreach($fldata as $value){
											$fcf.=EXT::GB($value['fname']).",";

										}
									$fcf=substr($fcf,0,-1);
							$fcf.="]},";
				
			$fcf=substr($fcf,0,-1);
			Tr($fcf,'fcf');	
		Tr($plugurl,'plugurl');
		Tr($plugjs,'plugjs');
		Tr($fckplugin,'fckplugin');
			
	Ts($tmpml.'add.html');
	break;}
	case 'save':{
			
		$id = $_POST['id'];
		$tree_id = $_POST['tid'];
 		$tree=Dgd(array(
						  'db'=>'d_sevenel',
						  'cd'=>"id = $tree_id",
						  'tn'=>"tree",
						  'limit'=>'1'
						));
		$tabname = gettabname($tree['table'],'',true);
		$fld=Dgd(array(
					'db'=>'d_sevenel',
					'cd'=>"tid = $tree_id",
					'tn'=>"fld"
				));
/*		if(!$id){
		$wyyz='user';
 		$wztemp=Dgd(array(
						  'db'=>'d_sevenel',
						  'cd'=>"$wyyz like '".$_POST[$wyyz]."'",
						  'tn'=>$tabname,
						  'limit'=>'1'
						));
		if($wztemp!=''){
				ext_request_failure('用户名已存在');
				exit();
			}
		}
*/		foreach($fld as $key => $value){
			switch($value['type']){
				case 'datefield':{
					if($value['zy']!=1){
						if(strtotime($_POST[$value['fname']])){
							$save[$value['fname']] = strtotime($_POST[$value['fname']]);
							}else{
							$save[$value['fname']]=$_POST[$value['fname']];
								}
						}else{
					$save[$value['fname']]=$_POST[$value['fname']];
							}
				break;}
				case 'checkboxgroup':{
					$save[$value['fname']]=implode("#_#",$_POST[$value['fname']]);
				break;}
				case 'password';{
					if($value['yxwk']=='1'){
						if($_POST[$value['fname']]==$_POST[$value['fname'].'-cfrm']){
							$save [$value['fname']] = md5($_POST[$value['fname']]);
						}else{
							ext_request_failure('两次输入不相同');
							exit();
						}
					}else{
						$save [$value['fname']] = md5($_POST[$value['fname']]);
					}
				break;}
			case 'fileup':{
					//print_r($_FILES);exit;
							if($_FILES[$value['fname']]['name']!=''){
							$cp=1;
								//复制文件
							$config=json_decode($value['cfg'],true);
							
							
							$dvalue=array( 0=>array('rar','zip','tar','.tz'),
										   1=>array('jpg','gif','png','bmp'),
										   2=>array('mp3','mp4','avi','wmv','mid','.rm','mvb','mov','wma','wav'),
										   3=>array('doc','xls','txt','ocx','lsx','ppt','pdf','chm'),
										   4=>array('doc','xls','txt','ocx','lsx','ppt','pdf','chm','mp3','mp4','avi','wmv','mid','.rm','mvb','mov','wma','wav','jpg','gif','png','bmp','rar','zip','tar','.tz')		   
												   );
								if(!$_FILES[$value['fname']]['name']){
									$cp=0;
								}
							$otype=substr(strtolower($_FILES[$value['fname']]['name']),-3);
							if(!in_array($otype,$dvalue[$config['type']])){
									$cp=0;
											header("Content-type: text/html; charset: UTF-8");
											echo "{success:true,msg:'%u4E0A%u4F20%u683C%u5F0F%u4E0D%u5141%u8BB8%21%u8BF7%u8054%u7CFB%u7BA1%u5458%21<BR> Upload format is not allowed! Please contact the administrator!'}";
											exit;
							}
							if($_FILES[$value['fname']]['size']/1000>$config['size']){
							$cp=0;
											header("Content-type: text/html; charset: UTF-8");
							echo "{success:true,msg:'%u6587%u4EF6%u5927%u5C0F%u8D85%u8FC7%u9650%u5236%21<br> The file size limit expired!'}";
							exit;
								}
						if($cp){
						$bsname=time();
						$bcname=$bsname.".".$otype;
						$filename="../../uplods/pic/".$bcname;
						$copymes=copy($_FILES[$value['fname']]['tmp_name'],$filename);
						$save[$value['fname']]=$bcname;
						}
						if(in_array($otype,$dvalue[1])){
							if($config['sl1']==1){
						@createthumb($_FILES[$value['fname']]['tmp_name'],".".$otype,$bsname,$config['sl1x'],$config['sl1y'],'1');
								}
								if($config['sl2']==1){
						@createthumb($_FILES[$value['fname']]['tmp_name'],".".$otype,$bsname,$config['sl2x'],$config['sl2y'],'2');
								}
								if($config['sypic']==1){
							$sypicname="../../uplods/sypic/".$bcname;
							$sypicwz="../../uplods/".$config['sytp']."";
							//echo $sypicwz ,$config['sytp'],$config['sywz'];
							@imageWaterMark($filename,$sypicname,$config['sypicwz'],$sypicwz,"",20,'wqy-microhei-lite.ttc',"#00FF00");
								}
								if($config['sytxt']==1){
							$sypicname="../../uplods/sytxt/".$bcname;
							$sypicwz="";
							@imageWaterMark($filename,$sypicname,$config['sytxtwz'],"",$config['sywz'],$config['sywzdx'],$config['syzt'],"#".$config['syys']);
								}
								if($config['sytxt']==1&&$config['sypic']==1){
							$filename="../../uplods/sypic/".$bcname;
							$sypicname="../../uplods/sytp/".$bcname;
							$sypicwz="";
							@imageWaterMark($filename,$sypicname,$config['sytxtwz'],"",$config['sywz'],$config['sywzdx'],$config['syzt'],"#".$config['syys']);
								}
								
								}
					}
				break;}
				default:{
				$save[$value['fname']]=$_POST[$value['fname']];
				}
			}
		}
			$save['tid'] = $tree_id;
			$save['lg'] = $_POST['lg'];
			!$save['lg']&&$save['lg']='zh';
			$_POST['bdid']&&$save['bdid']=$_POST['bdid'];
			$_POST['bdtid']&&$save['bdtid']=$_POST['bdtid'];
			$save['gid']=$_POST['gid'];
			!$save['gid']&&$save['gid']=Mct();
			$save['at']=time();
		//唯一性
		if($id!=0){
			if($listcf['editdisble'] !=''){
					foreach($listcf['editdisble'] as $tv){
							unset($save[$tv]);
						}
				}
		if(Du('sevenel',$tabname,$save,'id',$id,1))
			ext_request('ok');
		}else{
			if(Di('sevenel',$tabname,$save));
			ext_request('ok');
		}
	break;}
	case 'yuding':{
		$id = $_POST['id'];
 		$prodinfo=Dgd(array(
						  'db'=>'d_sevenel',
						  'cd'=>"id = $id",
						  'tn'=>"info",
						  'limit'=>'1'
						));
		if($prodinfo){
			$insert['tid']='108';
			$insert['tt']=$prodinfo['tt'];
			$insert['pic1']=$prodinfo['pic1'];
			$insert['ct']=$prodinfo['ct'];
			$insert['input2']=$prodinfo['input2'];
			$insert['input1']=$prodinfo['input1'];
			$insert['ubb1']=$prodinfo['ubb1'];
			$insert['input4']=$_SESSION['userinfo']['user'];
			$insert['input5']=$_POST['num'];
			$insert['input6']=$_POST['num']*$prodinfo['ct'];
			$insert['tj1']=2;
			$insert['lg']='zh';
			$insert['bdid']=$prodinfo['id'];
			$insert['bdtid']=$prodinfo['tid'];
			$insert['gid']=Mct();
			$insert['at']=time();
			Di('sevenel','info',$insert);
			echo "下单成功，等待卖家确认！";exit;
			}else{
			echo "产品出错,请仔细检查！";exit;
			}

	break;}
	case 'qkzd':{
		$save[$_POST['zd']]='';
		if(Du('sevenel',$_POST['tname'],$save,'id',$_POST['id'],1))
			ext_request('ok');	break;
			}
	case 'gxzd':{
		$save[$_POST['zd']]=$_POST['xz'];
		if(Du('sevenel',$_POST['tname'],$save,'id',$_POST['id'],1))
			ext_request('ok');	break;
			}
	case 'loaddata':{

		$tid=$_GET['tid'];
		Tr($tid,'tid');
 		$tree=Dgd(array(
		  'db'=>'d_sevenel',
		  'cd'=>"id = $tid",
		  'tn'=>"tree",
		  'limit'=>'1'
		  ));
		Tr($_GET['tid'],'tid');
		Tr($_GET['bdtid'],'bdtid');
		Tr($_GET['bdid'],'bdid');
			$tname=gettabname($tree['table'],$dbcfg['prefix'],true);
			Tr($tname,'tname');
		if($_GET['id']){
			Tr($_GET['id'],'id');
				$fdada=Dgd(array(
					  'db'=>'d_sevenel',
					  'cd'=>" id = '".$_GET['id']."' and del != '1' ",
					  'tn'=>"$tname",
					  'limit'=>1
					));
				Tr($fdada['gid'],'gid');
				$gid=$fdada['gid'];
				$fdada=Dgd(array(
					  'db'=>'d_sevenel',
					  'cd'=>" gid = '".$fdada['gid']."' and del != '1' ",
					  'tn'=>"$tname"
					));
				foreach($fdada as $value){
						$templg[$value['lg']]=$value['id'];
					}
				}
			!$gid&&$gid=Mct();
		if($tree['config']!=''){
			$tconfig=json_decode($tree['config'],true);
			$nowlg=explode('|',$tconfig['lg']);
				foreach($nowlg as $tv){
						$standlang[$tv]&&$xhlg[]=array('lg'=>$tv,'value'=>$standlang[$tv],'id'=>$templg[$tv],'gid'=>$gid);
					}
			if($xhlg){
				Tr($xhlg,'dy');
			}
		Tr($_GET['lg'],'slg');
		Ts($tmpml.'info.html');
		}
		break;
	}
	case 'loadfile':{
	if($_POST['node']==1||$_POST['node']==''){$path = "../../";};
	if($_POST['node']!=1&&$_POST['node']!=''){$path = $_POST['node'];};
     $f_arr = array();
     if( $handle = opendir( $path ) ) {
         while( false !== ( $file = readdir( $handle ) ) ) {
           if( $file != "." && $file != ".." && $file[0] != "." ) {
               if( !is_dir( $path . "/" . $file ) ){
				   $f_arr[] = $file;
					   $treetemp['text'] =$file;
					   $treetemp['leaf'] = true;
						$treetemp['iconCls'] ='file';
						$treetemp['action']=$path.$file;
						$treetemp['url']=$value['id'];
						$treetemp['id']=$path.$file;
				   }else{
				   $f_arr[] = $file;
					   $treetemp['text'] =$file;
					   $treetemp['leaf'] = false;
						$treetemp['iconCls'] = 'folder';
						$treetemp['action']='ml';
						$treetemp['url']=$value['id'];
						$treetemp['id']=$path.$file."/";
					 }
			$trees[] = $treetemp;
           }
         }
     }
   	closedir( $handle );
	echo json_encode($trees);				
		break;
		}
	default:{
		Ts($tmpml.'index.html');
		break;
	}
}

?>
